{"ast":null,"code":"import _objectSpread from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from'react';import{DropDownMenu,Name,UserStatus}from\"../\";import{DialogInput}from\"../../containers\";import{Context}from\"../../index\";import{Messages}from\"../../containers\";import{observer}from\"mobx-react-lite\";import{getOtherUserForNotMultiChat}from\"../../utils/Membership\";import'./Dialog.scss';import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";import{Fragment as _Fragment}from\"react/jsx-runtime\";var Dialog=function Dialog(){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _React$useState=React.useState(),_React$useState2=_slicedToArray(_React$useState,2),chat=_React$useState2[0],setChat=_React$useState2[1];var _React$useState3=React.useState(),_React$useState4=_slicedToArray(_React$useState3,2),otherUser=_React$useState4[0],setOtherUser=_React$useState4[1];React.useEffect(function(){if(store.currentDialog&&!store.currentDialog.multiChat&&store.currentDialog.membership&&store.currentDialog.membership.items.length>0){setOtherUser(getOtherUserForNotMultiChat(store,store.currentDialog.membership));}if(store.currentDialog.id){setChat(_objectSpread(_objectSpread({},chat),store.currentDialog));}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[store.currentDialog]);if(store.getViewedDialogId()){var _store$currentDialog$,_store$currentDialog$2;return/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__dialog\",children:[/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__dialog-header\",children:[/*#__PURE__*/_jsx(\"div\",{}),/*#__PURE__*/_jsxs(\"div\",{className:\"messenger__dialog-header-info\",children:[/*#__PURE__*/_jsx(\"p\",{className:\"messenger__dialog-header-name\",children:/*#__PURE__*/_jsx(Name,{user:otherUser,chatName:store.currentDialog.name,multiChat:store.currentDialog.multiChat})}),!store.getCurrentDialog().multiChat&&/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog-header-status\",children:/*#__PURE__*/_jsx(UserStatus,{status:true})})||/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog-header-countMemberships\",children:((_store$currentDialog$=store.currentDialog.membership)===null||_store$currentDialog$===void 0?void 0:_store$currentDialog$.items)&&/*#__PURE__*/_jsx(\"span\",{children:\"\\u0423\\u0447\\u0430\\u0441\\u0442\\u043D\\u0438\\u043A\\u043E\\u0432 \\u0432 \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u0435: \".concat(Object.keys((_store$currentDialog$2=store.currentDialog.membership)===null||_store$currentDialog$2===void 0?void 0:_store$currentDialog$2.items).length)})})]}),/*#__PURE__*/_jsx(DropDownMenu,{children:/*#__PURE__*/_jsx(_Fragment,{})})]}),/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog-messages\",children:/*#__PURE__*/_jsx(Messages,{})}),chat&&/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog-input\",children:/*#__PURE__*/_jsx(DialogInput,{chat:chat})})]});}else{return/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog\",children:/*#__PURE__*/_jsx(\"div\",{className:\"messenger__dialog-messages\",children:/*#__PURE__*/_jsx(Messages,{})})});}};export default observer(Dialog);","map":{"version":3,"names":["React","DropDownMenu","Name","UserStatus","DialogInput","Context","Messages","observer","getOtherUserForNotMultiChat","Dialog","useContext","store","useState","chat","setChat","otherUser","setOtherUser","useEffect","currentDialog","multiChat","membership","items","length","id","getViewedDialogId","name","getCurrentDialog","Object","keys"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/components/Dialog/index.tsx"],"sourcesContent":["import React from 'react';\nimport {DropDownMenu, Name, UserStatus} from \"../\";\nimport {DialogInput} from \"../../containers\";\nimport {Context} from \"../../index\";\nimport {Messages} from \"../../containers\";\nimport {observer} from \"mobx-react-lite\";\nimport {UserListItem} from \"../../models/response/UserListItem\";\nimport {getOtherUserForNotMultiChat} from \"../../utils/Membership\";\nimport {ChatsListItem} from \"../../models/response/ChatsListItem\";\nimport './Dialog.scss';\n\nconst Dialog = () => {\n    const {store} = React.useContext(Context);\n    const [chat, setChat] = React.useState<ChatsListItem>();\n    const [otherUser, setOtherUser] = React.useState<UserListItem>();\n\n    React.useEffect(() => {\n\n        if (store.currentDialog! &&\n            !store.currentDialog.multiChat &&\n            store.currentDialog.membership &&\n            store.currentDialog.membership.items.length > 0\n        ) {\n            setOtherUser(\n                getOtherUserForNotMultiChat(store, store.currentDialog.membership)\n            );\n        }\n\n        if (store.currentDialog.id) {\n            setChat({\n                ...chat,\n                ...store.currentDialog\n            });\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.currentDialog]);\n\n    if (store.getViewedDialogId()!) {\n        return (\n            <div className=\"messenger__dialog\">\n                <div className=\"messenger__dialog-header\">\n                    <div/>\n                    <div className=\"messenger__dialog-header-info\">\n                        <p className=\"messenger__dialog-header-name\">\n                            <Name user={otherUser} chatName={store.currentDialog.name} multiChat={store.currentDialog.multiChat} />\n                        </p>\n                        {(!store.getCurrentDialog().multiChat &&\n                                <div className=\"messenger__dialog-header-status\">\n                                    <UserStatus status={true} />\n                                </div>\n                            ) ||\n                            <div className=\"messenger__dialog-header-countMemberships\">\n                                {store.currentDialog.membership?.items &&\n                                    <span>\n                                    {`Участников в диалоге: ${Object.keys(store.currentDialog.membership?.items).length}`}\n                                </span>\n                                }\n                            </div>\n                        }\n                    </div>\n                    <DropDownMenu children={<></>} />\n                </div>\n                <div className=\"messenger__dialog-messages\">\n                    <Messages />\n                </div>\n                {chat &&\n                    <div className=\"messenger__dialog-input\">\n                        <DialogInput chat={chat} />\n                    </div>\n                }\n            </div>\n        );\n    } else {\n        return (\n            <div className=\"messenger__dialog\">\n                <div className=\"messenger__dialog-messages\">\n                    <Messages />\n                </div>\n            </div>\n        );\n    }\n}\n\nexport default observer(Dialog);"],"mappings":"2RAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,OAAQC,YAAY,CAAEC,I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